﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ReadLockDisposable.cs" company="">
//   
// </copyright>
// <summary>
//   The read lock disposable.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Skymate.Utilities.Threading
{
    using System;
    using System.Threading;

    /// <summary>
    ///     The read lock disposable.
    /// </summary>
    public sealed class ReadLockDisposable : IDisposable
    {
        /// <summary>
        ///     The _rw lock.
        /// </summary>
        private readonly ReaderWriterLockSlim _rwLock;

        /// <summary>
        /// Initializes a new instance of the <see cref="ReadLockDisposable"/> class.
        /// </summary>
        /// <param name="rwLock">
        /// The rw lock.
        /// </param>
        public ReadLockDisposable(ReaderWriterLockSlim rwLock)
        {
            this._rwLock = rwLock;
        }

        /// <summary>
        ///     The dispose.
        /// </summary>
        void IDisposable.Dispose()
        {
            this._rwLock.ExitReadLock();
        }
    }
}